﻿using CWY.Data.IRepository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CWY.Entities;

namespace CWY.Data.Repository
{
    public class AccountRepository : IAccountRepository, IDisposable
    {
        CWYEntities _entity = null;

        public AccountRepository() { _entity = new CWYEntities(); }
        public void AddAccount(tbl_account account)
        {
            try
            {
                _entity.tbl_account.Add(account);
                _entity.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }


        public IEnumerable<tbl_account> GetAccounts()
        {
            try
            {
                return _entity.tbl_account.ToList();
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public void Dispose()
        {
            _entity.Dispose();
        }
    }
}